package com.evil.common.account.dto.department;

import lombok.Data;
import lombok.EqualsAndHashCode;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

/**
 * 部门基础信息树
 *
 * @author liyang
 * @date 2022-08-08 00:00
 */
@Data
@EqualsAndHashCode(callSuper = true)
public class DepartmentBaseTreeRespDTO extends DepartmentBaseRespDTO implements Serializable {

    /**
     * 上级部门id
     */
    private Long parentDepartmentId;

    /**
     * 排序
     */
    private Integer sort;

    /**
     * 是否能选中
     */
    private Boolean canSelect;

    /**
     * 子级
     */
    private List<DepartmentBaseTreeRespDTO> children;

    public DepartmentBaseTreeRespDTO() {
        super();
        this.canSelect = true;
        this.children = new ArrayList<>();
    }

    public DepartmentBaseTreeRespDTO(Long departmentId, String departmentName, Long parentDepartmentId) {
        super(departmentId, departmentName);
        this.parentDepartmentId = parentDepartmentId;
        this.canSelect = true;
        this.children = new ArrayList<>();
    }

    public DepartmentBaseTreeRespDTO(Long departmentId, String departmentName, Long parentDepartmentId, Collection<Long> departmentIds) {
        super(departmentId, departmentName);
        this.parentDepartmentId = parentDepartmentId;
        this.canSelect = departmentIds.contains(departmentId);
        this.children = new ArrayList<>();
    }
}
